/*************************************************************************
 * AUTHOR		 : Chris Hayes
 * STUDENT ID	 : 656960
 * ASSIGNMENT #5 : Multi-Dimensional Array - Tic Tac Toe
 * CLASS		 : CS1B
 * SECTION		 : MW12:30
 * DUE DATE		 : June 15, 2011
 *************************************************************************/

#include "tictacheader.h"

/**************************************************************************
* FUNCTION DisplayBoard
*__________________________________________________________________________
* This function asks the users if they would like to play again.
*__________________________________________________________________________
* PRE-CONDITIONS
*  player1 : The name of player1 should be previously defined
*  player2 : The name of player2 should be previously defined
*
* POST-CONDITIONS
*   returns the answer, Y or N, as a character
*
**************************************************************************/

char PlayAgain(string player1, string player2)
{
	bool invalid;
	char answer;

	cout << player1 << " & " << player2 << " would you like to keep ";
	cout << "playing (y or n)? ";

	//ERROR CHECK INPUT - make sure answer is 'y' or 'n'
	do
	{
		invalid = false;

		cin.get(answer);
		cin.ignore(100, '\n');

		answer = toupper(answer);

		//OUTPUT ERROR
		if(answer != 'Y' && answer != 'N')
		{
			invalid = true;
			cout << "please enter y for YES or n for NO\n";
			cout << "Would you like to keep playing? ";
		}
	}while(invalid);

	return answer;
}
